import Layout from '@/layout/index.vue'

import { IconAlert, IconChart, IconHome, IconMenu } from '@/components/app-icons/index.js'

export const basicRoutes = [
  {
    name: '404',
    path: '/404',
    component: () => import('@/views/error-page/404.vue'),
    isHidden: true,
  },
  {
    name: 'REDIRECT',
    path: '/redirect',
    component: Layout,
    isHidden: true,
    children: [
      {
        name: 'REDIRECT_NAME',
        path: '',
        component: () => import('@/views/redirect/index.vue'),
      },
    ],
  },
  {
    name: 'LOGIN',
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    isHidden: true,
    meta: {
      title: '登录页',
    },
  },

  {
    name: 'Dashboard',
    path: '/',
    component: Layout,
    redirect: '/home',
    meta: {
      title: '首页',
      icon: IconChart,
    },
    children: [
      {
        name: 'Home',
        path: 'home',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: '总览',
          icon: IconHome,
        },
      },
    ],
  },
  //
  // {
  //   name: 'ErrorPage',
  //   path: '/error-page',
  //   component: Layout,
  //   redirect: '/error-page/404',
  //   meta: {
  //     title: '错误页',
  //     icon: IconAlert,
  //   },
  //   children: [
  //     {
  //       name: 'ERROR-404',
  //       path: '404',
  //       component: () => import('@/views/error-page/404.vue'),
  //       meta: {
  //         title: '404',
  //         icon: IconAlert,
  //       },
  //     },
  //   ],
  // },

  {
    name: 'Test',
    path: '/test',
    component: Layout,
    redirect: '/test/unocss',
    meta: {
      title: '基础功能测试',
      icon: IconMenu,
    },
    children: [
      {
        name: 'Message',
        path: 'message',
        component: () => import('@/views/test-page/message/index.vue'),
        meta: {
          title: '测试Message',
        },
      },
      {
        name: 'Dialog',
        path: 'dialog',
        component: () => import('@/views/test-page/dialog/index.vue'),
        meta: {
          title: '测试Dialog',
        },
      },
      {
        name: 'TestKeepAlive',
        path: 'keep-alive',
        component: () => import('@/views/test-page/keep-alive/index.vue'),
        meta: {
          title: '测试Keep-Alive',
          keepAlive: true,
        },
      },
    ],
  },
]

export const NOT_FOUND_ROUTE = {
  name: 'NotFound',
  path: '/:pathMatch(.*)*',
  redirect: '/404',
  isHidden: true,
}

const modules = import.meta.globEager('./modules/*.js')
const asyncRoutes = []
Object.keys(modules).forEach((key) => {
  asyncRoutes.push(...modules[key].default)
})
export { asyncRoutes }
